import java.util.Vector;



class P400_39643 {

	public static void main(String[] args) {
		
		String line = readLn();
		
		while (line != null) {
			process(Integer.parseInt(line));
			line = readLn();
		}
		
	}
	
	private static void process(int i) {
		
		int maxLength = 0;
		
		Vector v = new Vector();
		
		
		
		for (int k = 0; k < i; k++) {
			String string = readLn(); 
			if (!v.contains(string)) v.addElement(string);
			
		}
		 
		i = v.size();
		
		String[] array = new String[i];
		
		for (int k = 0; k < i; k++) {
			array[k] = (String) v.elementAt(k);
			if (array[k].length() > maxLength) maxLength = array[k].length();
		}
		
		
		int numberOfColumns = 0;
		int sum = 0;
		
		while (true) {
			
			if (sum > 60) break;
			
			numberOfColumns++;
			
			sum += maxLength;
			
//			if (sum > 60) break;
			
			sum += 2;
			
		}
		
		numberOfColumns--;
		
		if (numberOfColumns == 0) numberOfColumns++;
		
//		System.out.println(numberOfColumns);
	
		for (int k = 0; k < array.length; k++) {
			for (int j = k+1; j < array.length; j++) {
				if (array[k].compareTo(array[j]) > 0) {
					swap(array, k, j);
				}
			}
		}
		
		int value = i/numberOfColumns;
		
//		System.out.println(value);
		
		if (value * numberOfColumns != i) value++;
		
//		System.out.println(value);
		
		String[][] solution = new String[value][numberOfColumns];
		
		int index = 0;
		
		for (int x = 0; x < solution[0].length; x++) {
			for (int y = 0; y < solution.length; y++) {
				if (index < i)
					solution[y][x] = array[index];
				index++;
			}
		}
		
		for (int k = 0; k< 60; k++) {
			System.out.print("-");
		}
		System.out.println();
		
		for (int y = 0; y < solution.length; y++) {
			for (int x = 0; x < solution[y].length; x++) {
				
				if (solution[y][x] != null) {
					System.out.print(solution[y][x]);
					
					for (int k = solution[y][x].length() ; k < maxLength; k++) {
						System.out.print(" ");
					}
					
					if (!(x+1 == numberOfColumns && solution[y][x].length() == 60))
					
					/*if (x + 1 < numberOfColumns)*/ System.out.print("  ");
				}
			}
			System.out.println();
		}
		
	}

	private static void swap(String[] array, int k, int j) {
		String aux = array[k];
		array[k] = array[j];
		array[j] = aux;
	}

	static String readLn() {
		String newLine = System.getProperty("line.separator");
		StringBuffer buffer = new StringBuffer();
		int car = -1;
		try {
			car = System.in.read();
			while ((car > 0) && (car != newLine.charAt(0))) {
				buffer.append((char) car);
				car = System.in.read();
			}
			if (car == newLine.charAt(0))
				System.in.skip(newLine.length() - 1);
		} catch (java.io.IOException e) {
			return (null);
		}
		if ((car < 0) && (buffer.length() == 0))
			return (null);
		return (buffer.toString());
	}

	
}
